home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Resource for Source: C/C++
/
Resource for Source - C-C++.iso
/
codelib6
/
v_08_11
/
8n11103a
< prev
next >
Wrap
Text File
|
1995-11-01
|
1KB
|
49 lines
***********
Listing 3
#include <stdio.h>
typedef struct
{
char fname[25];
char lname[25];
} REC;
main()
{
REC rec, *recptr;
char charstr[25], *cptr;
int i;
/***********/
strcpy(rec.fname, "Stanley");
strcpy(rec.lname, "Cohen");
recptr = &rec;
cptr = recptr; /*** value of recptr is assigned to cptr
NO cast ***/
i = 0;;
while( charstr[i++] = *cptr++); /*** pointer arithmetic
on cptr ***/
puts(charstr); /*** first name is output to screen
***/
cptr = recptr;
printf("\n\address pointed to by cptr -> %d", cptr);
printf("\naddress pointed to by recptr -> %d", recptr);
cptr++;
recptr++;
printf("\n\naddress pointed to by cptr -> %d", cptr);
printf("\naddress pointed to by recptr -> %d", recptr);
}
**********